﻿<cfscript>
/** 
* ORM Course
* 
* @hint "Hibernate persistenter t_course. 课程号库 教学课程的基本数据项" 
* 
*/ 

component 
	displayname="public.service.orm.senate.Course" 
	output=false 
	persistent=true 
	selectBeforeUpdate=true dynamicInsert=true dynamicUpdate=true 
	cacheuse="Transactional" 
	entityname="Course" 
	table="t_course"
	{
		
	property type="string" name="CourseID" column="cid" fieldtype="id" generator="assigned" hint="课程号";

	property type="string" name="CourseName" column="course_name" hint="课程名称";
	property type="string" name="CourseEnglish" column="course_english" hint="课程英文名称";

	property type="numeric" name="Credit" column="course_credit" hint="学分";
	property type="numeric" name="Period" column="period" hint="总学时";
	property type="numeric" name="PeriodTheory" column="period_theory" hint="理论学时";
	property type="numeric" name="PeriodPractice" column="period_practice" hint="实践学时";
	property type="numeric" name="PeriodComputer" column="period_computer" hint="上机学时";
	property type="numeric" name="PeriodPerWeek" column="period_week" hint="排课周学时";

	property type="string" name="Intro" column="intro" hint="课程简介";
	property type="string" name="ReferenceBooks" column="reference_books" hint="参考书目";

	property type="string" name="CourseCode" column="course_code" hint="课程号";
	property type="string" name="MarkMode" column="mark_mode" hint="计分模式";
	property type="string" name="ResitPolicy" column="resit_policy" hint="补考安排规则";
	property type="string" name="Abandon" column="abandon" hint="停止开课";

	property name="WorkLoad" fieldtype="one-to-one" cfc="CourseWorkLoad" hint="课程工作量计算公式";

	property name="Institute" fieldtype="many-to-one" fkcolumn="institute_id" cfc="Institute"  hint="任课单位";
	property name="Catalog" fieldtype="many-to-one" fkcolumn="cat_id" cfc="CourseCatalog"  hint="课程分类目录";

	property name="CETCourses" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="CETCourse" hint="四六级考试成绩课程替代关系";

	property name="CourseBooks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="CourseBook" hint="学期教材选用";
	property name="StudentCourses" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="StudentCourse" hint="学生学期选课记录";
	property name="StudentMarks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="StudentMark" hint="学生成绩记录";
	property name="StudentTempMarks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="StudentMarkTemp" hint="学生成绩临时记录";
	property name="StudentTempResitMarks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="StudentMarkResitTemp" hint="学生补考成绩临时记录";
	property name="MarkAduits" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="StudentMarkAduit" hint="成绩更正记录";

	property name="CommonTasks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="CommonTask" hint="全校通选课";
	property name="OpenTasks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="OpenTask" hint="单开班课程";

	property name="ProgramSchemas" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="ProgramSchema" hint="各年级专业的培养方案";
	property name="ProgramPlans" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="ProgramPlan" hint="教学计划课程信息";
	property name="ProgramTasks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="ProgramTask" hint="计划课程";

	property name="ExamPlans" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="ExamPlan" hint="教学任务考试安排计划";
	property name="ExamMiddlePlans" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="ExamMiddlePlan" hint="教学任务半期考试安排计划";
	property name="ExamTasks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="ExamTask" hint="教学任务考试安排情况表";
	property name="ResitExamPlans" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="ExamResitPlan" hint="教学任务补考安排计划";
	property name="ResitExamTasks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="ExamResitTask" hint="补考任务考试安排情况表";

	property name="TaskArranges" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="TaskArrange" hint="教学任务课程安排";
	property name="TaskMarks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="TaskMark" hint="教学任务成绩提交状态";
	property name="TaskMarkUnlocks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="TaskMarkUnlock" hint="已提交成绩解锁业务流";
	property name="TaskWorkloads" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="TaskWorkload" hint="教学任务工作量汇总表";
	property name="TaskAdjusts" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cid" cfc="TaskAdjust" hint="教学任务更改情况记录";

	/**
	* @hint "自定义主键规则"
	*/
	public string function getNextID() output=false {
		
		var nextID = "1" & numberFormat(1, "0____");
		var checkArray = ORMExecuteQuery("select CourseID from Course 
											where CourseID like '1_____' 
											order by CourseID desc", {}, { maxResults=1 });

		/* 
			主键生成规则 CHAR(6)
			
			1起头 5位为流水号 本序列代码代表本、专科课程系列
		*/
		if (arrayLen(checkArray)) {
			/* 创建一个追加id */
			nextID = "1" & numberFormat((right(checkArray[1], 5) + 1), "0____");
			
		}

		return nextID;

	}

}

</cfscript>
